﻿using Aker.DevTeam;
using System;

namespace Aker
{
    public partial class UserSettings : XPopupForm
    {
        public UserSettings()
        {
            InitializeComponent();
        }

        public static int PriceType = 2;

        public static void Init()
        {
            Data.TAM.KullaniciSettingTableAdapter.Fill(Data.DB.KullaniciSetting);
            Data.TAM.UserSettingTableAdapter.Fill(Data.DB.UserSetting);

            int priceType = Data.GetUserSetting(1).ToIntNN();
            if (priceType != -1)
                PriceType = priceType;
        }

        private void Settings_Load(object sender, EventArgs e)
        {
            if (AppSession.Language == "TR")
            {
                chkPrices.Properties.Items.AddRange(new object[] {
                "Baz Fiyat",
                "Acenta Fiyatı",
                "Fuar Fiyatı",
                "Fiyat Ekstra"});
            }
            else
            {
                chkPrices.Properties.Items.AddRange(new object[] {
                "Base Price",
                "Agency Price",
                "Fair Price",
                "Fiyat Extra"});
            }

            chkPrices.SelectedIndex = PriceType.ToIntNN();
            this.Text = Language.MainForm.UserSettings;
            btnSave.Text = Language.Save;
            labelControl1.Text = Language.Settings.PriceType;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            PriceType = chkPrices.SelectedIndex;

            Data.SetUserSetting(1, PriceType.ToStringNN());

            Data.TAM.KullaniciSettingTableAdapter.Update(Data.DB.KullaniciSetting);

            this.Hide();
        }
    }
}